<div [formGroup]="form" class="age-input">
  <div>
    <mat-form-field>
      <input type="text" matInput [matDatepicker]="birthPicker" formControlName="birthday" placeholder="出生日期">
      <mat-datepicker-toggle matSuffix [for]="birthPicker"></mat-datepicker-toggle>
      <mat-error>日期不正确</mat-error>
      <mat-datepicker touchUi="true" #birthPicker></mat-datepicker>
    </mat-form-field>
  </div>
  <ng-container formGroupName='age'>
    <div class="age-num">
      <mat-form-field>
        <input type="text" placeholder="年龄" matInput formControlName="ageNum">
      </mat-form-field>
    </div>
    <div>
      <mat-button-toggle-group formGroupName="ageUnit" [(ngModel)]='selectedUnit'>
        <mat-button-toggle *ngFor="let unit of ageUnits" [value]="unit.value">{{unit.label}}</mat-button-toggle>
      </mat-button-toggle-group>
    </div>
    <!-- <mat-error *ngIf="form.get('age').hasError('ageInvalid')">年龄或单位不正确</mat-error> -->
    <mat-error class="mat-body-2" *ngIf="form.get('age').hasError('ageInvalid')">年龄或单位不正确</mat-error>
  </ng-container>
</div>
